close

abstract fun close()

Closes the current browser instance and releases all allocated resources.

The unload and beforeunload JavaScript events will not be fired in this case. This method is equivalent of close(CloseOptions.newBuilder().build()).

If the browser is already closed, then this method does nothing.

See also


abstract fun close(options: CloseOptions)

Closes the current browser instance according to the given options.

If the currently loaded web page registers the onbeforeunload JavaScript event and the given options tell the browser to fire the beforeunload event, then this method will not close the browser right away.

The com.teamdev.jxbrowser.browser.callback.BeforeUnloadCallback will be invoked in this case and if the callback tells the browser to stay on the web page, then the browser will not be closed.

The following example demonstrates how to close the browser instance as if a user manually clicking the close button of the tab/window.

browser.close(CloseOptions.newBuilder()
        .fireBeforeUnload()
        .build());

If the browser is already closed, then this method does nothing.

Since

7.6